package com.landeb.shop.huo.adapter;

import android.app.ProgressDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.landeb.shop.R;
import com.landeb.shop.huo.bean.ItemActInvoiceEdit;

import java.util.List;

/**
 * Created by blade on 2016/11/30.
 */

public class ActInvoiceEditLVAdapter extends BaseAdapter {

    private Context mContext;
    private List<ItemActInvoiceEdit> mList;
    private LayoutInflater mInflater;

    public ActInvoiceEditLVAdapter(Context context, List<ItemActInvoiceEdit> list) {
        mContext = context;
        mList = list;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = mInflater.inflate(R.layout.item_act_invoice_edit_lv, parent, false);

            holder = new ViewHolder();
            holder.mItem = (TextView) convertView.findViewById(R.id.tv_item_act_invoice_edit_lv);
            holder.mCheckBox = (CheckBox) convertView.findViewById(R.id.cb_item_act_invoice_edit_lv);

            convertView.setTag(holder);
        } else {

            holder = (ViewHolder) convertView.getTag();

        }

        holder.mItem.setText(mList.get(position).getItem());
        holder.mCheckBox.setChecked(mList.get(position).isChecked());

        return convertView;
    }

    private class ViewHolder {
        private TextView mItem; //文字
        private CheckBox mCheckBox;
    }

}
